package com.njym.java.security.app.util;

import com.github.wxpay.sdk.WXPayConfig;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

/**
 * @program: family-security
 *
 * @description:
 *
 * @author: lijie
 *
 * @create: 2020-02-25 13:28
 **/
public class WXConfigUtil   implements WXPayConfig {
    private byte[] certData;
    public     String APP_ID = "wxe2c2f21b418e8d23";
    public     String KEY = "1ac0967a59cc11eab289c8d3ffd4a2d1";
    public     String MCH_ID = "1577077161";

    public WXConfigUtil() throws Exception {
        //从微信商户平台下载的安全证书存放的路径
        String certPath = "D:\\微信证书\\apiclient_cert.p12";
        File file = new File(certPath);
        InputStream certStream = new FileInputStream(file);
        this.certData = new byte[(int) file.length()];
        certStream.read(this.certData);
        certStream.close();

    }

    @Override
    public String getAppID() {
        return APP_ID;
    }

    //parnerid，商户号
    @Override
    public String getMchID() {
        return MCH_ID;
    }

    @Override
    public String getKey() {
        return KEY;
    }

    @Override
    public InputStream getCertStream() {
        ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);
        return certBis;
    }

    @Override
    public int getHttpConnectTimeoutMs() {
        return 8000;
    }

    @Override
    public int getHttpReadTimeoutMs() {
        return 10000;
    }

}
